﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HR_Business
{
    public partial class Employee
    {
        HRDBContext _DatabaseContext;

        public Employee() : this(new HRDBContext()) { }

        public Employee(HRDBContext HRDBContext)
        {
            _DatabaseContext = HRDBContext;
        }

        public int Create(Employee newEmployee)
        {

            _DatabaseContext.Employees.AddObject(newEmployee);
            _DatabaseContext.SaveChanges();

            return newEmployee.Id;

        }

        public Employee GetEmployeeByEmployeeId(int employeeId)
        {
            return (_DatabaseContext.Employees.FirstOrDefault(employee => employee.Id == employeeId));
        }
    }
}
